The completed program is given below:
Here is the completed program. Be sure that you put the quote marks where they belong. If you forget just one of them, the compiler will become confused and would not translate your program!
class Haiku { public static void main ( String[] args ) { System.out.println("On a withered branch"); System.out.println("A crow has just alighted:"); System.out.println("Nightfall in autumn."); } }
If you have been creating the example programs and compiling and running them, you may have noticed that spaces and new lines in the program are not critical. (However, you can't put spaces in the middle of a word, and spaces inside the quote marks do matter.) For example, the following version of the program will compile correctly and will do exactly the same thing when it is run:
class Haiku{ public static void main(String[] args ) { System.out. println( "On a withered branch"); System . out.println("A crow has just alighted:" ); System.out.println("Nightfall in autumn."); }}
The compiler does not "see" the two dimensional lay-out of the program. It regards the program as a stream of characters, one following the other.
However, humans are sensitive to the lay-out of text, and it is important to be neat and consistent when you create a source file. Although the second version of the program runs correctly, it is much harder for a person to understand.